package testDice;

import static org.junit.Assert.*;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

import org.junit.Test;

import dice.RollDice;

public class testRollDice {

	@Test
	public void testRoll() throws Exception {
		String data = "\n";
		int result;
		
		InputStream testInput = new ByteArrayInputStream( data.getBytes("UTF-8") );
		InputStream old = System.in;
		
		try {
		    System.setIn( testInput );		
		    RollDice rd1 = new RollDice();
		    result = rd1.roll(10);
		} finally {
		    System.setIn( old );
		}
		assertEquals(1, result, 5);
	}

	@Test
	public void testGenerateValue() {
		RollDice rd1 = new RollDice();
		int result = rd1.generateValue();
		assertEquals(1, result, 5);
	}

	@Test
	public void testRoll2() {
		RollDice rd1 = new RollDice();
		int result = rd1.roll2(3);
		assertEquals(1, result, 2);
	}

}
